/**
 * Created by MadFrog on 2016/11/27.
 */
var WxConfig = {};
WxConfig.jsApiList = ['getLocation', 'scanQRCode', 'openLocation'];
(function () {
    //获取完整url
    var currentUrl = window.location.href;
    var params = {};
    params.currentUrl = currentUrl;
    $.ajax({
        type : "POST",
        url : ctx + "/getWechatJsConfig",
        data : params,
        dataType : "json",
        success : function (wechatReturn) {
            WxConfig.appId = wechatReturn.data.appId;
            WxConfig.timestamp = wechatReturn.data.timestamp;
            WxConfig.nonceStr = wechatReturn.data.nonceStr;
            WxConfig.signature = wechatReturn.data.signature;
            initWxConfig();
        }
    });
})();

function initWxConfig() {
    wx.config({
        debug: false,
        appId: WxConfig.appId,
        timestamp: WxConfig.timestamp,
        nonceStr: WxConfig.nonceStr,
        signature: WxConfig.signature,
        jsApiList: WxConfig.jsApiList
    });
    wx.error(function (res) {
        alert("微信JS-SDK config 失败" + res);
    });
}